using System;
using System.Collections.Generic;
using System.Linq;

namespace WIT.DAQ.Core.Models;

/// <summary>
/// 任务回写动作
/// </summary>
internal class TaskWriteback
{
	/// <summary>
	/// Id
	/// </summary>
	internal Guid Id { get; set; }

	/// <summary>
	/// 站点Id
	/// </summary>
	internal Guid StationId { get; set; }

	/// <summary>
	/// 采集项Id
	/// </summary>
	internal Guid DAQItemId { get; set; }

	/// <summary>
	/// 采集项
	/// </summary>
	internal DAQItem DAQItem { get; set; }

	/// <summary>
	/// 采集项名称
	/// </summary>
	public string DAQItemName => DAQItem.Name;

	/// <summary>
	/// 回写的内容来源（Const/Variable）
	/// </summary>
	internal string ContentSource { get; set; }

	/// <summary>
	/// 回写的内容来源名称（仅用于显示）
	/// </summary>
	public string ContentSourceName => ContentSources.FirstOrDefault((dynamic t) => t.Value == ContentSource).Name;

	/// <summary>
	/// 回写的内容
	/// </summary>
	public object Content { get; set; }

	/// <summary>
	/// 回写的内容来源列表（常量/变量）
	/// </summary>
	internal static List<dynamic> ContentSources => new List<object>
	{
		new
		{
			Name = "变量",
			Value = "Variable"
		},
		new
		{
			Name = "常量",
			Value = "Const"
		}
	};
}
